package com.rockcent.helper;

import com.rockcent.mall.lib.domain.enumclass.SystemType;
import com.rockcent.mall.lib.dto.UserInfoDto;
import com.rockcent.service.AuthUserService;
import com.rockcent.service.impl.BAuthUserServiceImpl;
import com.rockcent.service.impl.MAuthUserServiceImpl;
import com.rockcent.service.impl.RAuthUserServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by hone on 17-3-13.
 */
@Component
public class LoginFactoryHelper {

    @Autowired
    private RAuthUserServiceImpl rAuthUserService;
    @Autowired
    private MAuthUserServiceImpl mAuthUserService;
    @Autowired
    private BAuthUserServiceImpl bAuthUserService;

    /**
     * 区分R M B类型登录
     * @param systemType
     * @return
     */
    public AuthUserService createAuthService(String systemType) {
        if(StringUtils.isNotEmpty(systemType) && SystemType.valueOf(systemType) == SystemType.ADMIN) {
            return rAuthUserService;
        }
        if(StringUtils.isNotEmpty(systemType) && SystemType.valueOf(systemType) == SystemType.MALL) {
            return mAuthUserService;
        }
        if(StringUtils.isNotEmpty(systemType) && SystemType.valueOf(systemType) == SystemType.MERCHANT) {
            return bAuthUserService;
        }
        return bAuthUserService;
    }

}
